<template>
  <el-dialog
    :title="title"
    :close-on-click-modal="false"
    :visible.sync="visible"
    :before-close="cancel"
    class="JNPF-dialog JNPF-dialog_center"
    lock-scroll
    width="40%"
  >
    <el-row :gutter="15" class="">
      <el-form
        ref="elForm"
        :model="dataForm"
        :rules="rules"
        label-width="100px"
      >

        <el-col :span="24">
            <el-form-item label="所属设备商">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择">
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="24">
          <el-form-item label="仓库编号" class="required" prop="FCATNO">
            <el-input
              v-model="dataForm.FCATNO"
              placeholder="请输入"
              clearable
              :disabled="!insertorupdate"
              maxlength="8"
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item class="required" label="仓库名称" prop="FCATNAME">
            <el-input
              v-model="dataForm.FCATNAME"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item class="required" label="负责人" prop="FLINKNAME">
            <el-input
              v-model="dataForm.FLINKNAME"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item class="required" label="联系电话" prop="FTEL">
            <el-input
              v-model="dataForm.FTEL"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item class="required" label="备注" prop="FMEMO">
            <el-input
              v-model="dataForm.FMEMO"
              placeholder="请输入"
              clearable
              :style="{ width: '100%' }"
            >
            </el-input>
          </el-form-item>
        </el-col>

        <el-col :span="24">
          <el-form-item label="状态">
            <el-select v-model="dataForm.FSTATE" placeholder="请选择">
              <el-option
                v-for="item in options3"
                :key="item.value"
                :label="item.label"
                :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>

      </el-form>
    </el-row>
    <span slot="footer" class="dialog-footer">
      <el-button @click="cancel">取 消</el-button>
      <el-button  v-if="insertorupdate" type="primary" v-loading="loading">确 定</el-button>
      <el-button v-else type="primary"  v-loading="loading">修 改</el-button>
    </span>
  </el-dialog>
</template>
<script>
import jnpf from "@/utils/jnpf"
export default {
  props: {
    parelist: {
      type: Array,
      default: []
    },
  },
  data() {
    return {
        title:"新增",
        dataForm:{
          FCATNO: "101",
          FCATNAME: "宁波仓库",
          FLINKNAME: "韩信",
          FPARENTNO:"广州福兴实验室设备科技",
          FTEL:"135****9034",
          FMEMO:"存放化学实验所需设备&仪器",
          FSTATE: "正常"
        },
        rules: {
          FCATNO: [
                { required: true, message: '请输入仓库编号', trigger: 'blur' },
            ],
            FCATNAME: [
                { required: true, message: '请输入仓库名称', trigger: 'blur' },
            ],
        },

      //所属教学楼选择数据
      options1: [{
          value: '1',
          label: '广州福兴实验室设备科技'
        }, {
          value: '2',
          label: '江苏艾普瑞实验设备有限公司'
        }, {
          value: '3',
          label: '山东德瑞克仪器股份有限公司'
        }],

      //所属楼层选择数据
      options2: [{
        value: '20E01',
        label: '一楼'
      }, {
        value: '20E02',
        label: '二楼'
      }, {
        value: '20N01',
        label: '三楼'
      }, {
        value: '20N02',
        label: '四楼'
      }],

      //所属校区选择数据
      options3: [{
        value: '1',
        label: '正常'
      }, {
        value: '2',
        label: '停用'
      }],
      loading:false,
      visible:false,
      insertorupdate:true
    };
  },
  created() {
  },
  mounted() {},
  methods: {
    //
    init(id){
      this.dataForm.FCATNO= id || ''
        if(this.dataForm.FCATNO)
        {
            this.title="修改"
           this.insertorupdate=false;
        }
        else
        {
          this.insertorupdate=true;
            this.title="新增";
        }
        this.visible=true;
    },
    //
    cancel(){
        this.$refs.elForm.resetFields();
        this.visible=false;
    },
  },
};
</script>
